package com.hdax.easybuy.controller;

import com.hdax.easybuy.dao.ProductCategoryDao;
import com.hdax.easybuy.entity.ProductCategory;
import com.hdax.easybuy.service.ProductService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/providerProductCategory")
public class ProductCategoryController {
    @Resource
    private ProductCategoryDao productCategoryDao;
    @Resource
    private ProductService productService;


    @RequestMapping("/queryCategoryAll")
    @ResponseBody
    public List<ProductCategory> queryCategoryAll(){
        return productCategoryDao.findAll();
    }
    //根据父id查询所有的类别
    @RequestMapping("/queryByParentId/{id}")
    @ResponseBody
    public List<ProductCategory> queryAllProductCategory(@PathVariable("id") int id){

        return productCategoryDao.findByParentId(id);
    }


}
